{"ast":null,"code":"var _jsxFileName = \"/data/messenger.client/src/containers/DialogInput.tsx\",\n  _s = $RefreshSig$();\nimport React from \"react\";\nimport { DialogInput as DialogInputComponent } from \"../components\";\nimport { Context } from \"../index\";\nimport { observer } from \"mobx-react-lite\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst DialogInput = _ref => {\n  _s();\n  let {\n    chat\n  } = _ref;\n  const {\n    store\n  } = React.useContext(Context);\n  const [value, setValue] = React.useState(false);\n  const [textField, setTextField] = React.useState('');\n  const [emojiPickerVisible, setEmojiPickerVisible] = React.useState(false);\n  const pickerRef = React.useRef(null);\n  const maxSizeMessage = 500;\n  React.useEffect(() => {\n    if (textField.length > 0) {\n      setValue(true);\n    } else {\n      setValue(false);\n    }\n  }, [textField]);\n  React.useEffect(() => {\n    if (emojiPickerVisible) {\n      const handleClick = e => {\n        var _pickerRef$current;\n        if (!pickerRef.current) return;\n        if (!((_pickerRef$current = pickerRef.current) !== null && _pickerRef$current !== void 0 && _pickerRef$current.contains(e.target))) {\n          console.log(3e3);\n        }\n      };\n      document.addEventListener('click', handleClick);\n      return () => {\n        document.removeEventListener('click', handleClick);\n      };\n    }\n  }, [emojiPickerVisible]);\n  const toggleEmojiPicker = () => {\n    setEmojiPickerVisible(!emojiPickerVisible);\n  };\n  const uploadDocumentHandler = React.useCallback(e => {\n    let collectionFiles = [];\n    if (e.target.files) {\n      [...e.target.files].forEach(item => {\n        const file = item;\n        collectionFiles.push(file);\n      });\n    }\n    e.target.value = '';\n  }, [store]);\n  const handleSendMessage = e => {\n    if (textField.length - 1 <= maxSizeMessage) {\n      console.log(textField);\n      setTextField('');\n    }\n  };\n  return /*#__PURE__*/_jsxDEV(DialogInputComponent, {\n    toggleEmojiPicker: toggleEmojiPicker,\n    emojiPickerVisible: emojiPickerVisible,\n    value: value,\n    textField: textField,\n    setTextField: setTextField,\n    maxSizeMessage: maxSizeMessage,\n    uploadDocumentHandler: uploadDocumentHandler,\n    handleSendMessage: handleSendMessage,\n    pickerRef: pickerRef\n  }, void 0, false, {\n    fileName: _jsxFileName,\n    lineNumber: 64,\n    columnNumber: 9\n  }, this);\n};\n_s(DialogInput, \"BqkM7V9UXPLF5cPQ7efnhPhPWPo=\");\n_c = DialogInput;\nexport default _c2 = observer(DialogInput);\nvar _c, _c2;\n$RefreshReg$(_c, \"DialogInput\");\n$RefreshReg$(_c2, \"%default%\");","map":{"version":3,"names":["React","DialogInput","DialogInputComponent","Context","observer","chat","store","useContext","value","setValue","useState","textField","setTextField","emojiPickerVisible","setEmojiPickerVisible","pickerRef","useRef","maxSizeMessage","useEffect","length","handleClick","e","current","contains","target","console","log","document","addEventListener","removeEventListener","toggleEmojiPicker","uploadDocumentHandler","useCallback","collectionFiles","files","forEach","item","file","push","handleSendMessage"],"sources":["/data/messenger.client/src/containers/DialogInput.tsx"],"sourcesContent":["import React from \"react\";\nimport {DialogInputContainerProps} from \"../models/props/DialogInputContainerProps\";\nimport {DialogInput as DialogInputComponent} from \"../components\";\nimport {Context} from \"../index\";\nimport {observer} from \"mobx-react-lite\";\n\nconst DialogInput: React.FC<DialogInputContainerProps> = ({chat}) => {\n    const {store} = React.useContext(Context);\n    const [value, setValue] = React.useState<boolean>(false);\n    const [textField, setTextField] = React.useState<string>('');\n    const [emojiPickerVisible, setEmojiPickerVisible] = React.useState<boolean>(false);\n    const pickerRef = React.useRef<null | HTMLDivElement>(null);\n\n    const maxSizeMessage: number = 500;\n\n    React.useEffect(() => {\n        if (textField.length > 0) {\n            setValue(true);\n        } else {\n            setValue(false);\n        }\n    }, [textField]);\n\n    React.useEffect(() => {\n        if (emojiPickerVisible) {\n            const handleClick = (e: any) => {\n                if (!pickerRef.current) return;\n                if (!pickerRef.current?.contains(e.target)) {\n                    console.log(3e3)\n                }\n            }\n\n            document.addEventListener('click', handleClick);\n\n            return () => {\n                document.removeEventListener('click', handleClick)\n            }\n        }\n    }, [emojiPickerVisible]);\n\n    const toggleEmojiPicker = () => {\n        setEmojiPickerVisible(!emojiPickerVisible);\n    }\n\n    const uploadDocumentHandler = React.useCallback( (e: React.ChangeEvent<HTMLInputElement>) => {\n        let collectionFiles: File[] = [];\n        if (e.target.files) {\n            [...e.target.files].forEach((item) => {\n                const file: File = item;\n                collectionFiles.push(file);\n            });\n        }\n        e.target.value = '';\n    }, [store]);\n\n    const handleSendMessage = (e: React.ChangeEvent<HTMLInputElement>) => {\n        if (textField.length - 1 <= maxSizeMessage) {\n            console.log(textField);\n            setTextField('');\n        }\n    }\n\n    return (\n        <DialogInputComponent\n            toggleEmojiPicker={toggleEmojiPicker}\n            emojiPickerVisible={emojiPickerVisible}\n            value={value}\n            textField={textField}\n            setTextField={setTextField}\n            maxSizeMessage={maxSizeMessage}\n            uploadDocumentHandler={uploadDocumentHandler}\n            handleSendMessage={handleSendMessage}\n            pickerRef={pickerRef}\n        />\n    );\n}\n\nexport default observer(DialogInput);"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAAQC,WAAW,IAAIC,oBAAoB,QAAO,eAAe;AACjE,SAAQC,OAAO,QAAO,UAAU;AAChC,SAAQC,QAAQ,QAAO,iBAAiB;AAAC;AAEzC,MAAMH,WAAgD,GAAG,QAAY;EAAA;EAAA,IAAX;IAACI;EAAI,CAAC;EAC5D,MAAM;IAACC;EAAK,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACJ,OAAO,CAAC;EACzC,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAGT,KAAK,CAACU,QAAQ,CAAU,KAAK,CAAC;EACxD,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGZ,KAAK,CAACU,QAAQ,CAAS,EAAE,CAAC;EAC5D,MAAM,CAACG,kBAAkB,EAAEC,qBAAqB,CAAC,GAAGd,KAAK,CAACU,QAAQ,CAAU,KAAK,CAAC;EAClF,MAAMK,SAAS,GAAGf,KAAK,CAACgB,MAAM,CAAwB,IAAI,CAAC;EAE3D,MAAMC,cAAsB,GAAG,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